export default function(sequelize, DataTypes) {
  return sequelize.define('t_user', {
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: "主键id"
    },
    username: {
      type: DataTypes.STRING(20),
      allowNull: false,
      comment: "用户名",
      unique: "name_uni"
    },
    mobile: {
      type: DataTypes.CHAR(11),
      allowNull: true,
      comment: "手机号"
    },
    password: {
      type: DataTypes.CHAR(32),
      allowNull: false,
      comment: "密码32位MD5"
    },
    email: {
      type: DataTypes.STRING(350),
      allowNull: false,
      comment: "邮箱",
      unique: "email_uni"
    },
    auth_flag: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: "用户认证来源"
    },
    create_time: {
      type: DataTypes.CHAR(13),
      allowNull: false,
      comment: "创建时间"
    },
    invitation_code: {
      type: DataTypes.CHAR(6),
      allowNull: false,
      comment: "6位邀请码",
      unique: "inviter_uni"
    },
    inviter_id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "邀请者id"
    }
  }, {
    sequelize,
    tableName: 't_user',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
      {
        name: "name_uni",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "username" },
        ]
      },
      {
        name: "email_uni",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "email" },
        ]
      },
      {
        name: "inviter_uni",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "invitation_code" },
        ]
      },
    ]
  });
};
